<?php
$lang = Yii::app()->session['_lang'] ? : 'en';
?>
<section class="step_booking">
    <img src="<?= Yii::app()->theme->baseUrl ?>/images/step4_<?= $lang ?>.png">
    <article class="step2">
        <div class="nabar">
            <h2><?= $hotel_info->fullName; ?></h2>
        </div>
        <div class="confirm">
            <?php
            $temp = 0;
            foreach ($booked->matchRoom as $k => $v) {
                $checkIn = date('d M y', substr($k, 0, 10));
                $checkOut = date('d M y', substr($k, 10, 20));
                $checkInBooking = date('d-m-Y', substr($k, 0, 10));
                $checkOutBooking = date('d-m-Y', substr($k, 10, 20));
                ?>

                <div class="date">
                    1. <?= $checkIn; ?> to <?= $checkOut ?>
                </div>
                <div class="info-booked">
                    <?php
                    $temp++;
                    $totalPrice = 0;
                    foreach ($v as $key => $value) {
                        echo '<p>' . $value['adult'] . ' Adult(s), ' . $value['children'] . ' Child(ren), ' . $value['extrabed'] . ' Extrabed</p>';
                        echo '<p>' . strtoupper($value['roomTypeName']) . ' - ' . $value['promotion_name'] . '</p>';
                        echo '<p class="price">' . strtoupper($value['currency']) . ' ' . number_format($value['rate'], 2, '.', ',') . '</p>';
                        $totalPrice += $value['rate'];
                    }
                    ?>
                </div>
                <?php
            }
            if ($booked->airportInfo['tranferFee']['Status'] == 1):
                
                ?>
                <div class="date">
                    2. Arrival airport
                </div>
                <div class="info-booked">
                    <p class="price">
                        <?php
                        if ($booked->airportInfo['tranferFee']['Price'] == 0) {
                            echo 'Free pickup';
                        } else {
                            $totalPrice += $booked->airportInfo['tranferFee']['Price'];
                            echo strtoupper($value['currency']);
                            echo number_format($booked->airportInfo['tranferFee']['Price'], 2, '.', ',');
                        }
                        ?></p>
                </div>
                <?php
            endif;
            $vat = $totalPrice * $hotel_info->sales_tax / 100;
            $service_charge = ($totalPrice + $vat) * $hotel_info->service_charge_rate / 100;
            $grand_total = $vat + $service_charge + $totalPrice;
            ?>
            <table class="total">
                <tr>
                    <td class="col1 price">TOTAL:</td>
                    <td class="col2 price"><?= $value['currency'] ?> <?= number_format($totalPrice, 2, '.', ',') ?></td>
                </tr>
                <tr>
                    <td class="col1">Value Added Tax (VAT) <?= $hotel_info->sales_tax ?>%:</td>
                    <td class="col2"><?= number_format(round($vat, 2), 2, '.', ',') ?></td>
                </tr>
                <tr>
                    <td class="col1">Service Charge <?= $hotel_info->service_charge_rate ?>%:</td>                        
                    <td class="col2"><?= number_format(round($service_charge, 2), 2, '.', ',') ?></td>
                </tr>
                <tr>
                    <td class="col1 price">GRAND TOTAL:</td>
                    <td class="col2 price"><?= number_format(round($grand_total, 2), 2, '.', ',') ?></td>
                </tr>
            </table>                
        </div>

        <div class="confirm-submit" id="confirm_submit">
            <form action="confirm.html" method="post" data-ajax="false">
                <input type="submit" value="Confirm This Reservation" name="confirmation" data-role="false" id="btn_confirm">                
            </form>
        </div>
        <img src="<?php echo Yii::app()->theme->baseUrl; ?>/images/loading.gif" style="width:50px;display:none" id="loading">
    </article>

</section>